<div class="ibox float-e-margins">
    <div class="ibox-title">
        <h5>基本信息
            <small>user</small>
        </h5>
    </div>
    <div class="ibox-content">
        <form id="ajaxForm" class="form-horizontal">
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">用户名</label>

                    <div class="col-sm-4">
                        <input name="name" type="text" placeholder="请输入用户名" class="form-control"
                               value=''>
                    </div>
                    <span class="help-block m-b-none">请务必填写用户名</span>

                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">密码</label>

                    <div class="col-sm-4">
                        <input name="password" type="text" placeholder="请输入密码" class="form-control"
                               value=''>
                    </div>
                    <span class="help-block m-b-none">请务必填写密码</span>
                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">昵称</label>

                    <div class="col-sm-4">
                        <input name="nike_name" type="text" placeholder="请输入昵称" class="form-control"
                               value=''>
                    </div>
                    <span class="help-block m-b-none">(可选)</span>

                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">邮箱</label>

                    <div class="col-sm-4">
                        <input name="email" type="text" placeholder="请输入邮箱" class="form-control"
                               value=''>
                    </div>
                    <span class="help-block m-b-none">(可选)</span>

                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">手机</label>

                    <div class="col-sm-4">
                        <input name="phone" type="text" placeholder="请输入手机" class="form-control"
                               value=''>
                    </div>
                    <span class="help-block m-b-none">(可选)</span>

                </div>
            </div>
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">积分</label>

                    <div class="col-sm-4">
                        <input name="point" type="text" placeholder="请输入积分" class="form-control"
                               value=''>
                    </div>
                    <span class="help-block m-b-none">必须是数值</span>
                </div>
            </div>
           
            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">角色</label>

                    <div class="col-sm-4">
                        <div class="filter-box">
                            <div class="filter-text">
                                <input class="filter-title" type="text" readonly placeholder="请选择角色"/>
                                <i class="icon icon-filter-arrow"></i>
                            </div>
                            <select id="user_role_selector" name="user_role_id">
                                #for(role:dmsRoleList)
                                <option value="#(role.id)">#(role.name)</option>
                                #end
                            </select>
                        </div>
                    </div>
                    <span class="help-block m-b-none">请选择一个用户权限组</span>

                </div>
            </div>

            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">备注</label>

                    <div class="col-sm-4">
                        <input name="desc" type="text" placeholder="备注" class="form-control" value=''>
                    </div>
                    <span class="help-block m-b-none">(可选)</span>
                </div>
            </div>


            <div class="form-group">
                <div class="row">
                    <label class="col-sm-2 control-label">是否启用</label>

                    <div class="col-sm-4">
                        <input name="is_open" type="checkbox" class="js-switch" checked/>
                    </div>
                    <span class="help-block m-b-none">启用或者禁用</span>

                </div>
            </div>

            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    <button class="btn btn-primary" id="ajaxSubmit" type="button">保存内容</button>
                </div>
            </div>
        </form>
    </div>
</div>


<script>

    $(function () {
        $("#user_role_selector  option[value='0'] ").attr("selected", true)

        $("#ajaxSubmit").on("click", function () {
            var form = $("#ajaxForm");
            var formData = form.serializeObject();

            $.ajax({
                type: "POST",
                url: "postAdd",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(formData),
                dataType: "json",
                success: function (data) {

                    if (200 === data.code) {
                        showToast("保存成功", function () {
                            closePop();
                        });
                    } else {
                        swal("操作失败", "错误信息:" + data.msg, "error");
                    }
                },
                error: function (data) {
                    $("#ajaxSubmit").html("提交数据失败！");
                }
            });

        });


        //自定义样式
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });

        //仿IOS切换按钮
        var elem = document.querySelector('.js-switch');
        var switchery = new Switchery(elem, {
            color: '#1AB394'
        });

        //这里是初始化下拉选择
        $('.filter-box').selectFilter({
            callBack: function (val) {
                //返回选择的值
                console.log(val + '-是返回的值')
            }
        });


    });

</script>